package executor;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author tongchen
 * @create 2023-01-20 18:30
 */
public class TestPool {
    public static void main(String[] args) {
        //1.创建线程池
        ExecutorService fixedThreadPool = Executors.newFixedThreadPool(3);
        //创建循环并将任务不断加入线程池
        for (int i = 0; i <100 ; i++) {
            int taskId=i;
            fixedThreadPool.submit(()->{
                System.out.println("线程"+Thread.currentThread().getName()+"任务"+taskId);
            });
        }
    }
}
